package com.cxcs.cxcsojcodesandbox.security;

import java.security.Permission;

/**
 * 默认权限管理
 *
 * @Author: CxCS
 * @Version: 1.0
 * @Date: 2024-08
 */
public class DefaultSecurityManager extends SecurityManager {
    /**
     *  默认 允许所有权限
     * @param perm
     */
    @Override
    public void checkPermission(Permission perm) {
//        super.checkPermission(perm);  // 开启限制
    }

    // 限制读文件权限
    @Override
    public void checkRead(String file) {
//        throw new SecurityException("checkRead 权限异常：" + file);
    }

    // 限制写文件权限
    @Override
    public void checkWrite(String file) {
//        throw new SecurityException("checkWrite 权限异常：" + file);
    }

    // 限制执行文件权限
    @Override
    public void checkExec(String cmd) {
        throw new SecurityException("checkExec 权限异常：" + cmd);
    }

    // 限制网络连接权限
    @Override
    public void checkConnect(String host, int port) {
        throw new SecurityException("checkConnect 权限异常：" + host + ":" + port);
    }

}
